<include file="Public:add_header" />

<div>
    <form action="{:U(res/add)}" method="post" enctype="multipart/form-data" id="formdata" onsubmit="return checkform()">
      <div class="form-group">
        <label for="exampleInputEmail1">线报标题<span style="color: red">*</span>：</label>
        <input type="text" class="form-control" id="title" name="title" placeholder="线报标题">
      </div>
 
       <div class="form-group">
        <label for="exampleInputEmail1">线报链接：</label>
        <input type="text" class="form-control"  name="link" placeholder="线报链接">
      </div>
      <div class="form-group">
        <label for="exampleInputEmail1">原价：</label>
        <input type="text"  name="yuanjia"  id="yuanjia"  placeholder="当前价格">元
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

         <label for="exampleInputEmail1">券后价格：</label>
        <input type="text" name="current" id="current" placeholder="券后价格">元
      </div>

      <div class="form-group">

        <label for="exampleInputEmail1">选择类别：</label>

            <select class="btn btn-default dropdown-toggle" aria-haspopup="true" aria-expanded="false" name="category">
                 <option value="实时线报" selected="selected">实时线报</option>
                <option value="猫超整点包邮">猫超整点包邮</option>
                <option value="整点抢购">整点抢购</option>
                <option value="今日值得买">今日值得买</option>
                <option value="网站广告">网站公告</option>
                <option value="火爆热售">火爆热售</option>
                 <option value="置顶">置顶</option>
            </select>

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <label for="exampleInputEmail1">线报等级：</label>

            <select class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" name="level">
                <option value="0" selected="selected">游客</option>
                <option value="普通会员">普通会员</option>
                <option value="青铜会员">青铜会员</option>
                <option value="白银会员" >白银会员</option>
                <option value="黄金会员">黄金会员</option>
                <option value="铂金会员">铂金会员</option>
                <option value="钻石会员" >钻石会员</option>
                <option value="王者会员">至尊会员</option>
            </select> 
        </div>

      <div class="form-group">
        <label for="exampleInputEmail1">线报开始时间：</label>
        <input type="text"name="starttime" id="starttime" value="{$starttime}">
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

         <label for="exampleInputEmail1">线报关闭时间：</label>
        <input type="text" name="endtime" id="endtime" placeholder="默认不关闭">
      </div>

     <div class="form-group">
        <label for="exampleInputEmail1">来源：</label>
        <input type="text" class="form-control" name="from" placeholder="线报来源">
      </div>


    <div class="form-group">
        <label for="exampleInputEmail1">上传缩略图：</label>
        <input type="file" name="file">
      </div> 

       <div class="form-group">
          <label for="exampleInputEmail1">内容：</label>
          <textarea  id="content" name="content"></textarea>
      </div>

      <input type="submit" class="btn btn-primary" value="提交">
      <input type="reset" class="btn btn-default" value="重置">
 
    </form>

</div>


<script type="text/javascript">

   /*时间插件*/
    laydate.render({
      elem: '#starttime', //指定元素
      type: 'datetime'
    });


    laydate.render({
      elem: '#endtime', //指定元素
      type: 'datetime'
    });

  

     /*编辑器宽度自适应*/
    var screenWidth=screen.width;
 
    if (screenWidth>960) {
        screenWidth=1000;
    }
    var ue = UE.getEditor('content',{
            autoHeightEnabled: true,
            autoFloatEnabled: true,
            initialFrameWidth:screenWidth,
            initialFrameHeight:200
        });

    /*表单检测*/
    function checkform(){
      var title=$("#title").val();
      if (title==''||title==null) {
          alert('请填写线报标题');
          return false;
      }

    $.ajax({
        type: "POST",
        dataType: "json",
        data: $('#formdata').serialize(),
        url:"{:U('res/checkform')}",
        success: function(data){
          if (data.code==1) {
            alert(data.msg);
            return false;
           }else{
             alert('提交成功');
             window.location.href="{:U('res/index')}"; 
           }
        }

      });
 
      return false;
    }
</script>

<include file="Public:footer" />